{include file="public/header" /}
<body>
<div class="layui-card">
    <div class="layui-card-body">
        <div class="layui-tab-content">
            <form id="companyPicForm" class="layui-form layui-form-pane" autocomplete="off">
                <input type="hidden" name="id" value="{$info.id}">
                <div class="layui-form-item">
                    <label class="layui-form-label layui-required">名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" id="companyPicName" value="{$info.name}" class="layui-input" placeholder="请输入">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">排序</label>
                    <div class="layui-input-block">
                        <input type="text" name="sort" id="sort" value="{$info.sort}" class="layui-input" placeholder="请输入排序，数字越小，排序越靠前">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-block">
                        <input type="checkbox" name="status" id="status" {if $info.status == 1}checked {/if} lay-text="显示|隐藏" lay-skin="switch">
                    </div>
                </div>

                <div class="btn-block">
                    <button type="button" onclick="sendCompanyPic()" class="layui-btn layui-btn-normal">提交</button>
                </div>
            </form>
        </div>
    </div>
</div>
</body>

<script>
    layui.use('form',function () {
        var $ = layui.jquery,
            form = layui.form;
    })

    function sendCompanyPic() {
        if (emptyCheck($('#companyPicName').val())){
            hintMsg('请输入名称','companyPicName')
            return false
        }

        //弹出遮罩层，防止多次点击
        var companyPicEditLoad = layer.load(1,{shade:[0.5,'#FFF'],time:0})
        let data = $("#companyPicForm").serialize()
        ajaxRequest("{:url('category/editCompanyPicture')}",data,function (res) {
            if (res.code == 'suc'){
                sucMsg(res.msg,function () {
                    //刷新父级页面
                    parent.layui.table.reload('companyPicList')
                    //关闭遮罩层
                    layer.close(companyPicEditLoad)
                    //关闭当前弹出层
                    xadmin.close()
                })
            }else {
                errMsg(res.msg,function () {
                    //关闭遮罩层
                    layer.close(companyPicEditLoad)
                })
            }
        })
    }
</script>
</html>